var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), a = require("../../../@babel/runtime/helpers/asyncToGenerator"), e = require("../../../@babel/runtime/helpers/defineProperty"), s = getApp();

Page({
    data: {
        id: "",
        status: "",
        recordData: {},
        incomes: [],
        showPopup: !1,
        allCheck: !1,
        isOperation: !1,
        isShowSheet: !1,
        statusActions: [ {
            status: 1,
            name: "通过"
        }, {
            status: 3,
            name: "驳回"
        }, {
            status: -1,
            name: "无效"
        } ],
        batchIncomes: [],
        batchIncomesAll: [],
        reject_reason: "",
        show_reject_reason_pop: !1
    },
    onLoad: function(t) {
        t.id && (this.data.id = t.id), this.getData();
    },
    onReady: function() {},
    changeType: function(t) {
        var a = t.currentTarget.dataset.name;
        if (this.setData(e({}, a, t.detail)), "allCheck" == a) if (t.detail) {
            var s = this.data.batchIncomesAll.map(function(t) {
                return t + "";
            });
            this.setData({
                batchIncomes: s
            });
        } else this.setData({
            batchIncomes: []
        });
    },
    setShowPopup: function() {
        this.setData({
            showPopup: !this.data.showPopup
        });
    },
    showSheet: function(t) {
        var a = t.currentTarget.dataset.index;
        0 == this.data.status && this.setData({
            setIndex: a,
            isShowSheet: !0
        });
    },
    closeSheet: function() {
        this.setData({
            isShowSheet: !1
        });
    },
    changeStatus: function(t) {
        var a;
        this.setData((e(a = {
            isShowSheet: !1
        }, "incomes[".concat(this.data.setIndex, "].auditStatus"), t.detail.status), e(a, "incomes[".concat(this.data.setIndex, "].auditStatusText"), t.detail.name), 
        a));
    },
    getData: function() {
        var t = this, a = s.getNetAddresss("plugin.shop-assistant.frontend.withdraw.withdraw-detail");
        s._postNetWork({
            url: a,
            data: {
                id: this.data.id
            },
            success: function(a) {
                var e = a.data;
                if (1 != e.result) return s.tips(e.msg);
                var n = {};
                n.recordData = e.data, n.status = e.data.status, n.incomes = e.data.type_data ? e.data.type_data.incomes : [], 
                0 == n.status || -1 == n.status ? n.isOperation = !0 : n.isOperation = !1, n.batchIncomesAll = n.incomes.map(function(t) {
                    return t.id;
                }), t.setData(n);
            }
        });
    },
    clickBatchBotton: function(t) {
        var a = this;
        if (this.data.batchIncomes.length <= 0) return s.tips("请选择需要修改的记录");
        this.data.incomes.forEach(function(s, n) {
            var i = s.id + "";
            if (a.data.batchIncomes.includes(i)) {
                var o, r = t.currentTarget.dataset.params;
                a.setData((e(o = {}, "incomes[".concat(n, "].auditStatus"), r.status), e(o, "incomes[".concat(n, "].auditStatusText"), r.name), 
                o));
            }
        });
    },
    clickButton: function(t) {
        var a = this, e = t.currentTarget.dataset, s = e.type, n = e.opt, i = {
            id: this.data.id,
            submit_operation: s
        }, o = "";
        if (1 == s) if ("balance" == this.data.recordData.type) {
            if (i.status = n, 3 == n) return void this.setData({
                show_reject_reason_pop: !0
            });
        } else i.audit = {}, this.data.incomes.forEach(function(t) {
            t.auditStatus ? i.audit[t.id] = t.auditStatus : i.audit[t.id] = a.data.statusActions[0].status;
        }); else if (2 == s) o = "是否需要" + this.data.recordData.payment_button_name; else if (3 == s) o = "将重新审核记录,确认是否执行该操作!"; else if (5 == s) o = "重新打款一次，确认是否执行该操作!"; else {
            if (6 == s) return void this.setData({
                show_reject_reason_pop: !0
            });
            7 == s && (o = "本打款方式需要线下打款，系统只是完成流程!");
        }
        this.submitOperation(i, o);
    },
    submitOperation: function(e, n) {
        var i = this;
        return a(t.default.mark(function a() {
            var o;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    if (!n) {
                        t.next = 6;
                        break;
                    }
                    return t.next = 3, s.confirm(n);

                  case 3:
                    if (t.sent) {
                        t.next = 6;
                        break;
                    }
                    return t.abrupt("return");

                  case 6:
                    o = s.getNetAddresss("plugin.shop-assistant.frontend.withdraw.examine"), s._postNetWork({
                        url: o,
                        data: e,
                        success: function(t) {
                            var a = t.data;
                            if (1 != a.result) return s.tips(a.msg);
                            var e = {
                                status: "all",
                                recordData: {},
                                incomes: [],
                                showPopup: !1
                            };
                            i.setData(e), i.setData({
                                show_reject_reason_pop: !1
                            }), i.getData();
                        }
                    });

                  case 8:
                  case "end":
                    return t.stop();
                }
            }, a);
        }))();
    },
    reject_handle: function() {
        var t = {
            id: this.data.id,
            submit_operation: 6,
            reject_reason: this.data.reject_reason
        };
        "balance" == this.data.recordData.type && (t.submit_operation = 1, t.status = 3), 
        this.submitOperation(t);
    },
    onClickHide: function() {
        this.setData({
            show_reject_reason_pop: !1
        });
    },
    onChange: function(t) {
        this.setData({
            reject_reason: t.detail
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});